package cn.stacey.spring.ssm.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
/**
 * 拦截controller里面的方法
 */
public class InterceptorB implements HandlerInterceptor{
	/**
	 * 在controller方法执行之前运行(做登录判断，权限检查)
	 * 返回true的话，继续执行
	 * 返回false，   中断执行
	 */
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
	System.out.println("preHandleB");
		return true;
	}
	
	
	
	/**
	 * controller方法执行之后，但是在视图渲染之前
	 */

	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
			ModelAndView modelAndView) throws Exception {
	System.out.println("postHandleB");
	}
	
	
	/**
	 * controller方法执行之后，但是在视图渲染完毕
	 */

	@Override
	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
			throws Exception {
		System.out.println("afterCompletionB");
		
	}

}
